#include <iostream>
#include "Hand.h"

void Hand::add(Card *p_Card)
	{
		cards.push_back(p_Card);
	}

void Hand::clear()
	{
		cards.clear();
	}

int Hand::getTotal() const
	{
		int numberOfAces = 0;
		int result=0;
		int temp=0;
		if(!cards.empty())
		{
			for(int i=0;i<cards.size();++i)
			{
				temp = ((Card)(*cards[i])).getPoints();
				if(temp==1)
				{
					++numberOfAces;
				}
				result+=temp;
			}
			for(int j=0;j<numberOfAces;++j)
			{
				if(result>21)
				{
					result-=10;
				}
			}
		}
		return result;
	}

Card* Hand::getCard(int index) const
{
	return cards[index];
}

void Hand::printHandActual() const
{
	for(int i=0;i<cards.size();++i)
	{
		std::cout<<cards[i]->getPoints()<<" ";
	}
	std::cout<<this->getTotal();
}